package com.fishingwithme.infrastructure.dtos.credit;

import lombok.Data;

@Data
public class CreditAvailableDto {
    private Boolean isFulfill;
    private Integer availableCredit;
    private Integer ruleCredit;
    private Integer spotCredit;
    private Integer creditVal;
    private Integer difference;

    public void evaluateAvailable() {

        if (this.spotCredit != null) {
            Integer absSpotCredit = Math.abs(spotCredit);;
            this.isFulfill = availableCredit > absSpotCredit;
            this.creditVal = absSpotCredit;
            this.difference = availableCredit - absSpotCredit;

        } else {
            Integer absRuleCredit = Math.abs(ruleCredit);;
            this.isFulfill = availableCredit > absRuleCredit;
            this.creditVal = absRuleCredit;
            this.difference = availableCredit - absRuleCredit;
        }
    }
}
